package com.fau.wm.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.wm.action.PublicAction;
import com.fau.wm.entity.MedicalAdmin;
import com.fau.wm.entity.MedicalRecallDetail;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc  统计Action
 * @author liy
 * @datetime 2014年8月18日,上午10:28:41
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class StatisticsRecallAction extends PublicAction implements ModelDriven<MedicalRecallDetail> {

	private static final long serialVersionUID = 7115820449913302040L;
	
	private MedicalRecallDetail recallDetail = new MedicalRecallDetail();
	
	/**
	 * @desc 分页查询详细出库单
	 * @return null
	 * @author liy
	 * @datetime 2014年8月19日,下午5:00:19
	 */
	@Action(value = "statistics_recall_page")
	public String statisticsRecallPage(){
		this.map = ActionContext.getContext().getParameters();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		recallDetail.setHospitalId(admin.getEnterpriseId());
		this.pageBean = this.baseAllService.getStatisticsManagerService().findRecallDetailByPage(recallDetail, this.map);
		this.map.clear();
		map.put("total", this.pageBean.getTotalRow());
		map.put("data", this.pageBean.getResult());
		HttpServletResponse response = ServletActionContext.getResponse();
		formatJSON(response, this.map);
		return null;
	}
	
	/**
	 * @desc 进入出库统计页面
	 * @return SUCCESS
	 * @author liy
	 * @datetime 2014年8月18日,上午10:47:01
	 */
	@Action(value = "statistics_recall", results = {@Result(location = "statistics_recall.jsp")})
	public String statisticsRecall() {
		return SUCCESS;
	}
	
	public MedicalRecallDetail getRecallDetail() {
		return recallDetail;
	}

	public void setRecallDetail(MedicalRecallDetail recallDetail) {
		this.recallDetail = recallDetail;
	}

	@Override
	public MedicalRecallDetail getModel() {
		return recallDetail;
	}
	
	

}
